package io.renren.softpark.service.impl;

import com.yunlong.common.utils.PageUtils;
import com.yunlong.common.utils.Query;
import io.renren.softpark.dao.UserMyDao;
import io.renren.softpark.entity.UserEntity;
import io.renren.softpark.service.UserMyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import java.util.UUID;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



@Service("UserMyService")
public class UserMyServiceImpl extends ServiceImpl<UserMyDao, UserEntity> implements UserMyService {

    @Autowired
    private UserMyDao userMyDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserEntity> page = this.page(
                new Query<UserEntity>().getPage(params),
                new QueryWrapper<UserEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void saveUser(UserEntity user) {
        user.setCreateTime(new Date());
        user.setUpdateTime(new Date());
        String userId = UUID.randomUUID().toString().replace("-","");
        user.setUserId(userId);
        System.out.println(user.getUserId()+"----------------------------------------");
        userMyDao.insert(user);
    }

}